package com.spzx.product.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spzx.domain.Brand;
import com.spzx.product.mapper.BrandMapper;
import com.spzx.product.service.IBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;


/**
 * 品牌Service业务层处理
 */
@Service
public class BrandServiceImpl implements IBrandService {

    @Autowired
    private BrandMapper brandMapper;
    /**
     * 新增品牌
     *
     * @return
     */
    @Override
    public int addBrand(Brand brand) {
        return brandMapper.insert(brand);
    }

    /**
     * 修改品牌
     * @param brand
     * @return
     */
    @Override
    public int updateBrand(Brand brand) {
        brandMapper.update(brand);
        return 0;
    }

    /**
     * 根据id获取品牌
     * @param id
     * @return
     */
    @Override
    public Brand getBrand(Long id) {
        return brandMapper.getById(id);
    }

    /**
     * 根据分页查询品牌列表
     * @param brandPage
     * @param brand
     * @return
     */
    @Override
    public Page<Brand> pageList(Page<Brand> brandPage, Brand brand) {
        return brandMapper.selectByPage(brandPage,brand);
    }

    /**
     * 根据ids进行删除品牌
     * @param ids
     * @return
     */
    @Override
    public int deleteBrandByIds(Long[] ids) {
        return  brandMapper.deleteBatchIds(Arrays.asList(ids));
    }
}
